/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package consistency_check.business;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Chucho
 */
public class ConsistencyCheckBusiness {
    public List<ConsistencyCheckResult> checkAllDatabase(String database){
        List<ConsistencyCheckResult> results = new ArrayList<>();
        List<String> tables = new data_bases.business.DataBaseBusiness().getDatabaseTables(database);
        for(String table:tables){
            try {
                ResultSet resultset = new consistency_check.DAO.ConsistencyCheckDAO().checkTable(database,table, true);
                while(resultset.next()){
                    ConsistencyCheckResult result = new ConsistencyCheckResult();
                    result.setTableName(resultset.getString(1));
                    System.out.print(result.getTableName());
                    result.setOp(resultset.getString(2));
                    result.setMsgType(resultset.getString(3));
                    //System.out.println(" "+result.msgType);
                    result.setMsgText(resultset.getString(4));
                    results.add(result);
                }
            } catch (SQLException ex) {
                Logger.getLogger(ConsistencyCheckBusiness.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return results;
    }
}
